package hu.diploma.core.entity;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "group_table")
public class Group extends BaseEntity {

	@Column(name = "name")
	private String name;

	@ManyToOne
	private Device device;

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "group_table_person_table", joinColumns = @JoinColumn(name = "group_table_id"), inverseJoinColumns = @JoinColumn(name = "person_table_id"))
	private List<Person> people = new LinkedList<Person>();

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setDevice(Device device) {
		this.device = device;
	}

	public Device getDevice() {
		return device;
	}

	public void setPeople(List<Person> people) {
		this.people = people;
	}

	public List<Person> getPeople() {
		return people;
	}

}